import http from '../index'

// 分页获取订单
export const getOrders = ({ ascended = null, current = null, size = null, sortFieldName = null, createType = null, lineSid = null, orderCode = null, orderStatus = null, ownerType = null, payStatus = null, realDeliverySid = null, realPickerSid = null, receiveName = null, receivePhone = null, senderName = null, senderPhone = null }) => {
    return http.get("orders/page", { ascended, current, size, sortFieldName, createType, lineSid, orderCode, orderStatus, ownerType, payStatus, realDeliverySid, realPickerSid, receiveName, receivePhone, senderName, senderPhone })
}

// 根据sid获取订单
export const getOrderDetail = ({ sid }) => {
    return http.get("orders/by-sid/" + sid)
}

// 批量删除订单
export const delOrders = ({ sidList }) => {
    return http.put("orders/delete", { sidList })
}

// 代客下单
export const proxyCustomerPlaceOrder = ({ couponSid = null, ownerType = null, status = null, lineSid, orderGoods, preserveSid, receiveAddress, receiveDistrictCode, receiveLatitude, receiveLongitude, receiveName, receivePhone, reservationTimeRange, senderAddress, senderDistrictCode, senderLatitude, senderLongitude, senderName, senderPhone, userSid, vehicleSid }) => {
    return http.post("orders/help-create", { couponSid, ownerType, status, lineSid, orderGoods, preserveSid, receiveAddress, receiveDistrictCode, receiveLatitude, receiveLongitude, receiveName, receivePhone, reservationTimeRange, senderAddress, senderDistrictCode, senderLatitude, senderLongitude, senderName, senderPhone, userSid, vehicleSid })
}

// 用户下单
export const userPlaceOrder = ({ couponSid = null, ownerType = null, status = null, lineSid, orderGoods, preserveSid, realPickerSid, receiveAddressSid, reservationTimeRange, senderAddressSid, vehicleSid }) => {
    return http.post("orders/self-create", { couponSid, ownerType, status, lineSid, orderGoods, preserveSid, realPickerSid, receiveAddressSid, reservationTimeRange, senderAddressSid, vehicleSid })
}

// 订单信息修改
export const editOrder = ({ sid, orderGoods, receiveAddress, receiveDistrictCode, receiveLatitude, receiveLongitude, receiveName, receivePhone, senderAddress, senderDistrictCode, senderLatitude, senderLongitude, senderName, senderPhone }) => {
    return http.put("orders/update/" + sid, { orderGoods, receiveAddress, receiveDistrictCode, receiveLatitude, receiveLongitude, receiveName, receivePhone, senderAddress, senderDistrictCode, senderLatitude, senderLongitude, senderName, senderPhone })
}

// 获取预估价格
export const getOrderEstPrice = ({ goodsNormsSid = null, goodsWeight = null, normsNumber = null, couponSid = null, lineSid, preserveSid, pricingTypeSid, vehicleSid }) => {
    return http.get("orders/pre-price", { goodsNormsSid, goodsWeight, normsNumber, couponSid, lineSid, preserveSid, pricingTypeSid, vehicleSid })
}

// 后台订单补款
export const compensateOrderPrice = ({ sid, afterAmount, note = null, status = null }) => {
    return http.put("orders/adjust/create/" + sid, { afterAmount, note, status })
}

// 后台退款审核
export const examineOrderRefund = ({ sid, sign, note = null }) => {
    return http.put("orders/examine/" + sid, { sign, note })
}

// 获取订单调整记录
export const getOrderAdjustRecord = ({ sid }) => {
    return http.get("orders/adjust/query/" + sid)
}


// 查看订单退款进度
export const getOrderRefundProgress = ({ sid }) => {
    return http.get("orders/" + sid + '/refund-schedule')
}

// 后台补款订单打款
export const payCompensatoryOrder = ({ sid }) => {
    return http.put('orders/payment/' + sid)
}

// 查询出勤状态正常的取货员
export const getWorkPickers = ({ orderSid }) => {
    return http.get("orders/" + orderSid + "/pickers")
}

// 修改取货员
export const changeOrderPicker = ({ orderSid, pickerSid }) => {
    return http.put("orders/" + orderSid, {
        pickerSid
    })
}